package com.example;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;

public class DirectoryCreate {

    private final List<File> result = new ArrayList<>();
    private final Pattern p = Pattern.compile(".*\\.dll", Pattern.CASE_INSENSITIVE);

    private void SearchFile (File dir){

        File[] files = dir.listFiles(file -> {
            if(file.isDirectory()) {
    
                SearchFile(file);
                return false;
            }
            else{
                return p.matcher(file.getName()).matches();
            }
          });

          if(files != null){
            result.addAll(Arrays.asList(files));
          }
    }

    public List<File> GetFilesResult(File path){

        SearchFile(path);
        return result;
    }
}
